package com.digitalart.futbol.service.controller;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.digitalart.futbol.hibernate.ejb.Cancha;
import com.digitalart.futbol.hibernate.service.CanchaService;

/**
 * Handles requests for the application home page.
 */
@Controller
@RequestMapping(value="/cancha")
public class CanchaController {
	
	public static final Logger logger = LoggerFactory.getLogger(CanchaController.class);
	
	@Autowired
	private CanchaService canchaServ;
 
	@RequestMapping(value = "/getAll", method = RequestMethod.GET)
	public @ResponseBody List<Cancha> getAll() {
		
		List<Cancha> result = canchaServ.findByAll();
		
		return result;
		
	}
	
	
	@RequestMapping(value = "/get{id}", method = RequestMethod.GET)
	public @ResponseBody Cancha getById(@PathVariable("id") int id) {
		
		Cancha result = canchaServ.retriveCancha(id);
		
		return result;
		
	}
	
}
